#! /usr/bin/perl -w

#   E:\perl_dev\post_hz.pl   
use LWP;
use Encode;
use IO::String;
use Getopt::Long;

#use String;

use HTTP::Headers;
use HTTP::Cookies;
use HTTP::Request;
use HTTP::Response;
use HTTP::Status;


  
    
my $postarg ={
'callCount'=>'1',
'page'=>'/member/t.shtml',
'httpSessionId'=>'CDBC75107BEF0ABBF344898AA25086A2',
'scriptSessionId'=>'6C893CF0E833F8A258C1284884EE8BE5944',
'c0-scriptName'=>'phonebookService',
'c0-methodName'=>'laodEConnection',
'c0-id'=>'0',
'c0-param0'=>'string:70163990',
'batchId'=>'9',
};



$fdPhone = get_dat($postarg);

print $fdPhone;
        


#print get_dat($postarg); 




# 换行调用
sub get_dat{
    
    local ($subarg) = @_; 

    my $url = 'http://woshiug.sinaapp.com/get.php';
    #$url ='http://www.hozom.com/dwr/call/plaincall/phonebookService.laodEConnection.dwr';
    #print  $postarg;
    my $c = &do_POST( $url,$subarg,)
        or die (     encode("gbk", decode("utf8", "连接失败\n") )   );

    # 返回所有数据 
    #print $c; 
    return $c;
    
}

# 访问接口
sub do_POST {

    my $url = 'http://woshiug.sinaapp.com/get.php';
    my $login_url = 'http://woshiug.sinaapp.com/get.php';
    my $cookie = 'sdaf=lkj;s=sse343';
    
    my $browser = LWP::UserAgent->new;
    $browser->agent("Mozilla/9.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6");
    #死cookie
    $browser->default_header('Cookie'=>$cookie,'Referer'=>$login_url);
    #$browser->default_header('jjyy'=>'woshiugaaaa','Referer'=>$url );
    
    #活 自动 cookie
    $cookie_jar = HTTP::Cookies->new(file => "d:\\temp\\cookies.dat", autosave => 1);
    $browser->cookie_jar($cookie_jar);
    
    my $resp = $browser->post(@_);
    #直接 访问
    #my $request= new HTTP::Request(GET=>$url);
    #   $request->header('Cookie' => 'JSESSIONID=C6329F4FDC17FC57866BE8A0E2704762');   
    #my $resp  = $browser->request($request);
    
    #print $resp;
    if ($resp->is_success) {
        return $resp->content;   
    }
    else {
        return $resp->status_line;
    }
 
 
}


#   E:\perl_dev\post_hz.pl   


